import * as _ from 'lodash/core';
import * as moment from 'moment';

@Inject('$log', 'bookService')
class technicalDisclosureController {
  constructor() {
    $log.debug('Hello from technicalDisclosureController controller!');
    this.lodash_version = _.VERSION;
    this.moment_version = moment.version;

    this.init();
  }

  init() {
    this.data = {
      list: [
        {
          id: 1,
          name: '123',
        },
        {
          id: 2,
          name: '333',
        },
      ],
      currentIndex: -1,
    };

    this.method = {
      formate: (data) => {
        this.data.formateList = [];
        data.forEach((item) => {
          this.data.formateList.push(item);
          this.data.formateList.push(item);
        });
        this.data.list = this.data.formateList;
      },
      // 控制展开关闭
      controlExpand: ($index) => {
        if ($index % 2 === 1) {
          return;
        }
        if (this.data.currentIndex === $index + 1) {
          this.data.currentIndex = -1;
        } else {
          this.data.currentIndex = $index + 1;
        }
      },
    };

    this.pagination = {
      totalItems: 123,
      currentPage: 1,
      maxSize: 5,
      pageChanged() {
        // $log.debug(this.currentPage);
      },
    };

    this.method.formate(this.data.list);
  }
}

export default technicalDisclosureController;
